From 5785c77a00e7c54a2b9627d7cc58152ed8c7b002 Mon Sep 17 00:00:00 2001 From: Marius Hoch Date: Thu, 23 Jan 2014 21:02:34 +0100 Subject: [PATCH] Ignore certain tidy warnings in assertValidHtmlDocument Those aren't really useful, especially as tidy often cries about parameters missing which have been deprecated since HTML 4, so that these warnings have no value for us. Change-Id: Ic27c597aa988079ed08e152861bf1dee9581b829 --- tests/phpunit/MediaWikiTestCase.php | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/tests/phpunit/MediaWikiTestCase.php b/tests/phpunit/MediaWikiTestCase.php index 95b50474ad..87e214cb9e 100644 --- a/tests/phpunit/MediaWikiTestCase.php +++ b/tests/phpunit/MediaWikiTestCase.php @@ -1003,7 +1003,18 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase { $this->markTestSkipped( 'Tidy extension not installed' ); } - $ok = MWTidy::checkErrors( $html, $errors ); - $this->assertTrue( $ok, 'HTML validation errors: ' . $errors ); + $errorBuffer = ''; + MWTidy::checkErrors( $html, $errorBuffer ); + $allErrors = preg_split( '/[\r\n]+/', $errorBuffer ); + + // Filter Tidy warnings which aren't useful for us. + // Tidy eg. often cries about parameters missing which have actually + // been deprecated since HTML4, thus we should not care about them. + $errors = preg_grep( + '/^(.*Warning: (trimming empty|.* lacks ".*?" attribute).*|\s*)$/m', + $allErrors, PREG_GREP_INVERT + ); + + $this->assertEmpty( $errors, implode( "\n", $errors ) ); } } -- 2.20.1